package com.xcdh.trading.entity;

import com.baomidou.mybatisplus.annotation.OrderBy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
@TableName("day_transaction_data")
public class DayTransactionData {
    @TableId
    private Long id;          // 主键ID
    private String tsCode;    // 股票代码
    @TableField(value = "`name`")
    private String name ;
    private String tradeDateCode; // 交易日期
    @OrderBy(sort = 1)
    private String tradeDate; // 交易日期
    @TableField(value = "`open`")
    private Float open;       // 开盘价
    private Float high;       // 最高价
    private Float low;        // 最低价
    @TableField(value = "`close`")
    private Float close;      // 收盘价
    private Float preClose;   // 昨收价
    @TableField(value = "`change`")

    private Float change;     // 涨跌额
    private Float pctChg;     // 涨跌幅
    private Float vol;        // 成交量
    private Float amount;     // 成交额

    /**
     * 换手率（%）
     */
    @TableField(value = "turnover_rate" )
    @OrderBy(sort = 6)
    private Float turnoverRate;

    /**
     * 量比
     */
    @TableField(value = "volume_ratio"  )
    private Float volumeRatio;

    public Float hotAmount ;

    public Float bigAmount ;
    public Float smallAmount ;
    private Integer upNum;
    private Integer downNum;
    private BigDecimal pctChgSum;

    @TableField(value = "zf_num_sum")
    private Integer  zfNumSum ;

    @TableField(value = "df_num_sum")
    @OrderBy(sort = 4 , isDesc = false)
    private Integer  dfNumSum ;

    /*涨跌比例*/
    @TableField( value = "zd_ratio")
    @OrderBy(sort = 5)
    private Integer zdRatio ;
    @TableField( value = "zdf_ratio")
    @OrderBy(sort = 2)
    private Integer  zdfRatio ;

    @TableField( value = "zdf_num")
    @OrderBy(sort = 3)
    private Integer  zdfNum ;


    public Float getShowPrice(){
        if(pctChg < 0){
            return -close ;
        }
        return close ;
    }

    public String getZdNumStr(){
        return String.format("%s/%s" ,upNum , downNum ) ;
    }
    public String getZdfNumStr(){
        return String.format("%s#%s/%s" , zdfRatio ,zfNumSum , dfNumSum ) ;
    }
}
